﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Classes
{
    public partial class FormConfBancoDados2 : Form
    {
        public FormConfBancoDados2()
        {
            InitializeComponent();
        }

        private void btnSalvar_Click(object sender, EventArgs e)
        {
            INIFile ini = new INIFile(Application.StartupPath + "\\Conf.INI");

            ini.IniWriteValue("CONFDB2", "host", tbxServer.Text);
            ini.IniWriteValue("CONFDB2", "db", tbxDB.Text);
            ini.IniWriteValue("CONFDB2", "user", tbxUser.Text);
            ini.IniWriteValue("CONFDB2", "pwd", tbxSenha.Text); //StringCipher.Encrypt("12345678", tbxSenha.Text));

            ini.IniWriteValue("CONFDB2", "host2", tbxServer2.Text);
            ini.IniWriteValue("CONFDB2", "db2", tbxDB2.Text);
            ini.IniWriteValue("CONFDB2", "user2", tbxUser2.Text);
            ini.IniWriteValue("CONFDB2", "pwd2", tbxSenha2.Text); //StringCipher.Encrypt("12345678", tbxSenha.Text));

            this.Close();
        }

        private void FormConfBancoDados2_Load(object sender, EventArgs e)
        {
            INIFile ini = new INIFile(Application.StartupPath + "\\Conf.INI");

            tbxServer.Text = ini.IniReadValue("CONFDB2", "host");
            tbxDB.Text = ini.IniReadValue("CONFDB2", "db");
            tbxUser.Text = ini.IniReadValue("CONFDB2", "user");
            if (ini.IniReadValue("CONFDB2", "pwd") != "")
                tbxSenha.Text = ini.IniReadValue("CONFDB2", "pwd"); //StringCipher.Decrypt("12345678", ini.IniReadValue("CONFDB", "pwd"));

            tbxServer2.Text = ini.IniReadValue("CONFDB2", "host2");
            tbxDB2.Text = ini.IniReadValue("CONFDB2", "db2");
            tbxUser2.Text = ini.IniReadValue("CONFDB2", "user2");
            if (ini.IniReadValue("CONFDB2", "pwd2") != "")
                tbxSenha2.Text = ini.IniReadValue("CONFDB2", "pwd2"); //StringCipher.Decrypt("12345678", ini.IniReadValue("CONFDB", "pwd"));
        }

        private void btnSair_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
